<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							订单编号：<input type="text" name="formNum" id="formNum"/>
						</li>
						<li>
							归属平台：<select   name="deptId" id="productDeptId">
								<option value="">请选择归属平台</option>
							</select>

						</li>

						<li>
							录单员：<select   name="createBy" id="createBy">
                            <option value="">请选择录单员</option>
                        </select>
						</li>
					</ul>
					<ul>
						<li>
							产品：<select   name="enterProductId" id="enterProductId">
							<option value="">请选择产品</option>
						</select>
						</li>
						<li class="select-time">
							<label>注册时间： </label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="enter:enter:add">-->
				<!--<i class="fa fa-plus"></i> 录入-->
			<!--</a>-->
			<!--<a class="btn btn-primary " onclick="checkAllEnterForm()" shiro:hasPermission="enter:enter:checkAll">-->
				<!--<i class="fa fa-check"></i> 审核-->
			<!--</a>-->
			<a class="btn btn-warning" onclick="exportExcel()" shiro:hasAllPermissions="analysis:analysis:export">
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    // var editFlag = [[${@permission.hasPermi('enter:enter:edit')}]];
    // var removeFlag = [[${@permission.hasPermi('enter:enter:remove')}]];
    var prefix = ctx + "analysis/analysis";

    $(function () {
        getAllProduct()
        getAllDept()
        getAllEnterUser()
    })

    function exportExcel(){
        window.location.href =prefix+'/exportExcel?formNum='+$("#formNum").val()+"&deptId="+$("#productDeptId").val()+"&createBy="+$("#createBy").val()+"&enterProductId="+$("#enterProductId").val()
		+"&beginTime="+$("#startTime").val()+"&endTime="+$("#endTime").val();
	}
    // 查询所有的产品名称
    function getAllProduct() {
        $.ajax({
            type: "GET",
            url: prefix +'/allProduct',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].id+"'>"+data[i].productName + "</opinion>"
                    $("#enterProductId").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }

    // 获取所有的平台信息
    function getAllDept() {
        $.ajax({
            type: "GET",
            url: prefix +'/allDeptT',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].deptId+"'>"+data[i].deptName + "</opinion>"
                    $("#productDeptId").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }

    // 获取所有的录单员
    function getAllEnterUser() {
        $.ajax({
            type: "GET",
            url: prefix +'/getUserByRoeId',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].userId+"'>"+data[i].userName + "</opinion>"
                    $("#createBy").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }
    $(function() {
        var options = {
            url: prefix + "/list",
            // createUrl: prefix + "/add",
            // updateUrl: prefix + "/edit/{id}",
            // removeUrl: prefix + "/remove/{id}",
            // checkAllUrl: prefix + "/checkAll",
            uniqueId: "id",
            // exportUrl: prefix + "/export",
            // sortName: "roleSort",
            // modalName: "订单基本信息",
            columns: [
                {
                    field: 'Number',
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index + 1;
                    },
                },
                {
                    field: 'id',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '录单员',
                },
                {
                    field: 'today',
                    title: '日期',
                },
                {
                    field: 'deptName',
                    title: '平台',
                },
                {
                    field: 'shopName',
                    title: '店铺',
                },
                {
                    field: 'productName',
                    title: '产品名称',
                },
                {
                    field: 'formNum',
                    title: '订单号',
                },

                // {
                //     field: 'wwNum',
                //     title: '旺旺号',
                // },
                // {
                //     field: 'webChatNum',
                //     title: '微信号',
                // },

                {
                    field: 'orderPrice',
                    title: '订单金额',
                },
                {
                    field: 'commission',
                    title: '佣金',
                },
                {
                    field: 'goodRecord',
                    title: '好评数',
                },
                {
                    field: 'goodPrice',
                    title: '好评单价',
                },
                {
                    field: 'formNature',
                    title: '订单性质',
                },
                {
                    field: 'remark',
                    title: '备注',
                },
                ]
        };
        $.table.init(options);
    });


    // 审核订单信息
    function checkAllEnterForm() {
        var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
        alert(rows)
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要审核选中的" + rows.length + "条数据吗?", function() {
            var url = prefix + "/checkAll";
            var data = { "ids": rows.join() };
            $.operate.submit(url, "post", "json", data);
        });
    }







</script>
</body>
</html>